using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace Yoozoo.Gameplay.City
{
    public class CityRealAiQueueMoodHUD : CityRealAiProgressBarHUD
    {
        [Serializable]
        public struct QueueMoodConfig
        {
            // 等待事件
            public float timestamp;
            // 替换表情
            public Sprite moodSprite;
            // 替换进度条
            public Sprite progressSprite;
        }
        
        [SerializeField]
        protected SpriteRenderer _Mood;

        [SerializeField]
        protected QueueMoodConfig[] _MoodConfigs;

        private int _CurrentConfigIndex;
        
        public override void SetProgressBar(float duration)
        {
            _CurrentConfigIndex = 0;
            UpdateSpriteRenderers();
            
            base.SetProgressBar(duration);
        }
        
        // Update is called once per frame
        protected override void Update()
        {
            int nextConfigIndex = _CurrentConfigIndex + 1;
            if (nextConfigIndex<_MoodConfigs.Length && _Timer>=_MoodConfigs[nextConfigIndex].timestamp)
            {
                _CurrentConfigIndex = nextConfigIndex;
                UpdateSpriteRenderers();
            }
            
            base.Update();
        }

        void UpdateSpriteRenderers()
        {
            _ProgressBar.sprite = _MoodConfigs[_CurrentConfigIndex].progressSprite;
            if (_MPB != null)
            {
                _ProgressBar.GetPropertyBlock(_MPB);
            }
            _Mood.sprite = _MoodConfigs[_CurrentConfigIndex].moodSprite;
        }
        
    }
}
